using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Management;
using System.Text;
using System.Windows.Forms;

namespace csharpsysinfo
{
    public partial class DrivesForm : Form
    {
        public DrivesForm()
        {

            InitializeComponent();
        }
        private string GetHdModel()
        {
            string hdModelString;
            int hdCounterInteger;

            hdCounterInteger = 1;

            hdModelString = "Failed to retrieve info.";


                ManagementObjectSearcher managementobjectsearcher = new ManagementObjectSearcher
                ("SELECT * FROM  Win32_DiskDrive");

                ManagementObjectCollection managementobjectcollection = managementobjectsearcher.Get();

                foreach (ManagementObject mob in managementobjectcollection)
                {
                    try
                    {
                        if (hdCounterInteger == 1)
                        {
                          hdModelString = mob.Properties["Model"].Value.ToString();
                          hdModelTextBox.Text = hdModelString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 2)
                        {
                        hdModelString = mob.Properties["Model"].Value.ToString();
                        hdModel2TextBox.Text = hdModelString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                       if (hdCounterInteger == 3)
                       {
                          hdModelString = mob.Properties["Model"].Value.ToString();
                          hdModel3TextBox.Text = hdModelString;

                       }
                    }
                    catch
                    {
                    }

                    try
                    {
                         if (hdCounterInteger == 4)
                        {
                            hdModelString = mob.Properties["Model"].Value.ToString();
                              hdModel4TextBox.Text = hdModelString;

                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 5)
                        {
                            hdModelString = mob.Properties["Model"].Value.ToString();
                            hdModel5TextBox.Text = hdModelString;

                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 6)
                         {
                             hdModelString = mob.Properties["Model"].Value.ToString();
                             hdModel6TextBox.Text = hdModelString;

                         }
                    }
                    catch
                    {
                    }
                    //hdModelTextBox.Text = hdModelTextBox.Text + hdModelString;
                    hdCounterInteger++;

                    //if empty
                    if (hdModelTextBox.Text == "")
                    {
                        hdModelTextBox.Text = "Failed to retrieve info.";
                    }
                    if (hdModel2TextBox.Text == "")
                    {
                        hdModel2TextBox.Text = "Failed to retrieve info.";
                    }

                    if (hdModel3TextBox.Text == "")
                    {
                        hdModel3TextBox.Text = "Failed to retrieve info.";
                    }
                    
                    if (hdModel4TextBox.Text == "")
                    {
                        hdModel4TextBox.Text = "Failed to retrieve info.";
                    }

                    if (hdModel5TextBox.Text == "")
                    {
                        hdModel5TextBox.Text = "Failed to retrieve info.";
                    }

                    if (hdModel6TextBox.Text == "")
                    {
                        hdModel6TextBox.Text = "Failed to retrieve info.";
                    }
                }
            

            return hdModelString;
        
        }

        private string GetHdManufacturer()
        {
            string hdManufacturerString;
            int hdCounterInteger;

            hdCounterInteger = 1;

            hdManufacturerString = "Failed to retrieve info.";


                ManagementObjectSearcher managementobjectsearcher = new ManagementObjectSearcher
                ("SELECT * FROM  Win32_DiskDrive");

                ManagementObjectCollection managementobjectcollection = managementobjectsearcher.Get();

                foreach (ManagementObject mob in managementobjectcollection)
                {
                    try
                    {
                        if (hdCounterInteger == 1)
                        {
                            hdManufacturerString = mob.Properties["Manufacturer"].Value.ToString();
                            hdManufacturerTextBox.Text = hdManufacturerString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 2)
                        {
                            hdManufacturerString = mob.Properties["Manufacturer"].Value.ToString();
                            hdManufacturer2TextBox.Text = hdManufacturerString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 3)
                        {
                            hdManufacturerString = mob.Properties["Manufacturer"].Value.ToString();
                            hdManufacturer3TextBox.Text = hdManufacturerString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 4)
                        {
                            hdManufacturerString = mob.Properties["Manufacturer"].Value.ToString();
                            hdManufacturer4TextBox.Text = hdManufacturerString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 5)
                        {
                            hdManufacturerString = mob.Properties["Manufacturer"].Value.ToString();
                            hdManufacturer5TextBox.Text = hdManufacturerString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 6)
                        {
                            hdManufacturerString = mob.Properties["Manufacturer"].Value.ToString();
                            hdManufacturer6TextBox.Text = hdManufacturerString;
                        }
                    }
                    catch
                    {
                    }

                    hdCounterInteger++;
                }

            return hdManufacturerString;

        }
        private string GetHdSignature()
        {
            string hdSignatureString;
            int hdCounterInteger;

            hdCounterInteger = 1;

            hdSignatureString = "Failed to retrieve info.";

            try
            {
                ManagementObjectSearcher managementobjectsearcher = new ManagementObjectSearcher
                ("SELECT * FROM  Win32_DiskDrive");

                ManagementObjectCollection managementobjectcollection = managementobjectsearcher.Get();

                foreach (ManagementObject mob in managementobjectcollection)
                {
                    try
                    {
                        if (hdCounterInteger == 1)
                        {
                            hdSignatureString = mob.Properties["Signature"].Value.ToString();
                            hdSigTextBox.Text = hdSignatureString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 2)
                        {
                            hdSignatureString = mob.Properties["Signature"].Value.ToString();
                            hdSig2TextBox.Text = hdSignatureString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 3)
                        {
                            hdSignatureString = mob.Properties["Signature"].Value.ToString();
                            hdSig3TextBox.Text = hdSignatureString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 4)
                        {
                            hdSignatureString = mob.Properties["Signature"].Value.ToString();
                            hdSig4TextBox.Text = hdSignatureString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 5)
                        {
                            hdSignatureString = mob.Properties["Signature"].Value.ToString();
                            hdSig5TextBox.Text = hdSignatureString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 6)
                        {
                            hdSignatureString = mob.Properties["Signature"].Value.ToString();
                            hdSig6TextBox.Text = hdSignatureString;
                        }
                    }
                    catch
                    {
                    }

                    hdCounterInteger++;
                    }
            }
            catch
            {
            }
            return hdSignatureString;

        }
        private string GetHdTotalHeads()
        {
            string hdTotalHeadsString;
            int hdCounterInteger;

            hdCounterInteger = 1;

            hdTotalHeadsString = "Failed to retrieve info.";


                ManagementObjectSearcher managementobjectsearcher = new ManagementObjectSearcher
                ("SELECT * FROM  Win32_DiskDrive");

                ManagementObjectCollection managementobjectcollection = managementobjectsearcher.Get();

                foreach (ManagementObject mob in managementobjectcollection)
                {
                    try
                    {
                        if (hdCounterInteger == 1)
                        {
                            hdTotalHeadsString = mob.Properties["TotalHeads"].Value.ToString();
                            hdTotalHeadsTextBox.Text = hdTotalHeadsString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 2)
                        {
                            hdTotalHeadsString = mob.Properties["TotalHeads"].Value.ToString();
                            hdTotalHeads2TextBox.Text = hdTotalHeadsString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 3)
                        {
                            hdTotalHeadsString = mob.Properties["TotalHeads"].Value.ToString();
                            hdTotalHeads3TextBox.Text = hdTotalHeadsString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 4)
                        {
                            hdTotalHeadsString = mob.Properties["TotalHeads"].Value.ToString();
                            hdTotalHeads4TextBox.Text = hdTotalHeadsString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 5)
                        {
                            hdTotalHeadsString = mob.Properties["TotalHeads"].Value.ToString();
                            hdTotalHeads5TextBox.Text = hdTotalHeadsString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 6)
                        {
                            hdTotalHeadsString = mob.Properties["TotalHeads"].Value.ToString();
                            hdTotalHeads6TextBox.Text = hdTotalHeadsString;
                        }
                    }
                    catch
                    {
                    }

                    hdCounterInteger++;
                }

            return hdTotalHeadsString;

        }


        private string GetHdFirmwareRev()
        {
            string hdFirmwareRevString;
            int hdCounterInteger;

            hdCounterInteger = 1;

            hdFirmwareRevString = "Failed to retrieve info.";


                ManagementObjectSearcher managementobjectsearcher = new ManagementObjectSearcher
                ("SELECT * FROM  Win32_DiskDrive");

                ManagementObjectCollection managementobjectcollection = managementobjectsearcher.Get();

                foreach (ManagementObject mob in managementobjectcollection)
                {
                    try
                    {
                        if (hdCounterInteger == 1)
                        {
                            hdFirmwareRevString = mob.Properties["FirmwareRevision"].Value.ToString();
                            hdFirmwareRevTextBox.Text = hdFirmwareRevString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 2)
                        {
                            hdFirmwareRevString = mob.Properties["FirmwareRevision"].Value.ToString();
                            hd2FirmwareRevTextBox.Text = hdFirmwareRevString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 3)
                        {
                            hdFirmwareRevString = mob.Properties["FirmwareRevision"].Value.ToString();
                            hd3FirmwareRevTextBox.Text = hdFirmwareRevString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 4)
                        {
                            hdFirmwareRevString = mob.Properties["FirmwareRevision"].Value.ToString();
                            hd4FirmwareRevTextBox.Text = hdFirmwareRevString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 5)
                        {
                            hdFirmwareRevString = mob.Properties["FirmwareRevision"].Value.ToString();
                            hd5FirmwareRevTextBox.Text = hdFirmwareRevString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 6)
                        {
                            hdFirmwareRevString = mob.Properties["FirmwareRevision"].Value.ToString();
                            hd6FirmwareRevTextBox.Text = hdFirmwareRevString;
                        }
                    }
                    catch
                    {
                    }
                    hdCounterInteger++;
                }

            return hdFirmwareRevString;
        }

        private string GetHdFileSystem()
        {
            string hdFileSystemString;
            int hdCounterInteger;

            hdCounterInteger = 1;

            hdFileSystemString = "Failed to retrieve info.";


                ManagementObjectSearcher managementobjectsearcher = new ManagementObjectSearcher
                ("SELECT * FROM  Win32_LogicalDisk where drivetype=2 OR drivetype=3");
                //drivetype is for removable or fixed discs only so we can get flash drives

                ManagementObjectCollection managementobjectcollection = managementobjectsearcher.Get();

                foreach (ManagementObject mob in managementobjectcollection)
                {
                    try
                    {
                        if (hdCounterInteger == 1)
                        {
                            hdFileSystemString = mob.Properties["FileSystem"].Value.ToString();
                            hdFileSystemTextBox.Text = hdFileSystemString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 2)
                        {
                            hdFileSystemString = mob.Properties["FileSystem"].Value.ToString();
                            hd2FileSystemTextBox.Text = hdFileSystemString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 3)
                        {
                            hdFileSystemString = mob.Properties["FileSystem"].Value.ToString();
                            hd3FileSystemTextBox.Text = hdFileSystemString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 4)
                        {
                            hdFileSystemString = mob.Properties["FileSystem"].Value.ToString();
                            hd4FileSystemTextBox.Text = hdFileSystemString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 5)
                        {
                            hdFileSystemString = mob.Properties["FileSystem"].Value.ToString();
                            hd5FileSystemTextBox.Text = hdFileSystemString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 6)
                        {
                            hdFileSystemString = mob.Properties["FileSystem"].Value.ToString();
                            hd6FileSystemTextBox.Text = hdFileSystemString;
                        }
                    }
                    catch
                    {
                    }

                    hdCounterInteger++;
                }

            return hdFileSystemString;
        }

        private string GetHdInterfaceType()
        {
            string hdInterfaceTypeString;
            int hdCounterInteger;

            hdCounterInteger = 1;

            hdInterfaceTypeString = "Failed to retrieve info.";


                ManagementObjectSearcher managementobjectsearcher = new ManagementObjectSearcher
                ("SELECT * FROM  Win32_DiskDrive");

                ManagementObjectCollection managementobjectcollection = managementobjectsearcher.Get();

                foreach (ManagementObject mob in managementobjectcollection)
                {
                    try
                    {
                        if (hdCounterInteger == 1)
                        {
                            hdInterfaceTypeString = mob.Properties["InterfaceType"].Value.ToString();
                            hdInterfaceTypeTextBox.Text = hdInterfaceTypeString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 2)
                        {
                            hdInterfaceTypeString = mob.Properties["InterfaceType"].Value.ToString();
                            hd2InterfaceTypeTextBox.Text = hdInterfaceTypeString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 3)
                        {
                            hdInterfaceTypeString = mob.Properties["InterfaceType"].Value.ToString();
                            hd3InterfaceTypeTextBox.Text = hdInterfaceTypeString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 4)
                        {
                            hdInterfaceTypeString = mob.Properties["InterfaceType"].Value.ToString();
                            hd4InterfaceTypeTextBox.Text = hdInterfaceTypeString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 5)
                        {
                            hdInterfaceTypeString = mob.Properties["InterfaceType"].Value.ToString();
                            hd5InterfaceTypeTextBox.Text = hdInterfaceTypeString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 6)
                        {
                            hdInterfaceTypeString = mob.Properties["InterfaceType"].Value.ToString();
                            hd6InterfaceTypeTextBox.Text = hdInterfaceTypeString;
                        }
                    }
                    catch
                    {
                    }

                    hdCounterInteger++;
                }

            return hdInterfaceTypeString;
        }

        private string GetHdSerialNumber()
        {
            string hdSerialNumberString;
            int hdCounterInteger;

            hdCounterInteger = 1;

            hdSerialNumberString = "Failed to retrieve info.";


                ManagementObjectSearcher managementobjectsearcher = new ManagementObjectSearcher
                ("SELECT * FROM  Win32_DiskDrive");

                ManagementObjectCollection managementobjectcollection = managementobjectsearcher.Get();

                foreach (ManagementObject mob in managementobjectcollection)
                {
                    try
                    {
                        if (hdCounterInteger == 1)
                        {
                            hdSerialNumberString = mob.Properties["SerialNumber"].Value.ToString();
                            hdSerialNumberTextBox.Text = hdSerialNumberString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 2)
                        {
                            hdSerialNumberString = mob.Properties["SerialNumber"].Value.ToString();
                            hd2SerialNumberTextBox.Text = hdSerialNumberString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 3)
                        {
                            hdSerialNumberString = mob.Properties["SerialNumber"].Value.ToString();
                            hd3SerialNumberTextBox.Text = hdSerialNumberString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 4)
                        {
                            hdSerialNumberString = mob.Properties["SerialNumber"].Value.ToString();
                            hd4SerialNumberTextBox.Text = hdSerialNumberString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 5)
                        {
                            hdSerialNumberString = mob.Properties["SerialNumber"].Value.ToString();
                            hd5SerialNumberTextBox.Text = hdSerialNumberString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 6)
                        {
                            hdSerialNumberString = mob.Properties["SerialNumber"].Value.ToString();
                            hd6SerialNumberTextBox.Text = hdSerialNumberString;
                        }
                    }
                    catch
                    {
                    }

                    hdCounterInteger++;
                }

            return hdSerialNumberString;
        }

        private string GetHdSize()
        {
            string hdSizeString;
            int hdCounterInteger;

            hdCounterInteger = 1;

            hdSizeString = "Failed to retrieve info.";


                ManagementObjectSearcher managementobjectsearcher = new ManagementObjectSearcher
                ("SELECT * FROM  Win32_DiskDrive");

                ManagementObjectCollection managementobjectcollection = managementobjectsearcher.Get();

                foreach (ManagementObject mob in managementobjectcollection)
                {
                    try
                    {
                        if (hdCounterInteger == 1)
                        {
                            hdSizeString = mob.Properties["Size"].Value.ToString();
                            hdSizeTextBox.Text = hdSizeString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 2)
                        {
                            hdSizeString = mob.Properties["Size"].Value.ToString();
                            hd2SizeTextBox.Text = hdSizeString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 3)
                        {
                            hdSizeString = mob.Properties["Size"].Value.ToString();
                            hd3SizeTextBox.Text = hdSizeString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 4)
                        {
                            hdSizeString = mob.Properties["Size"].Value.ToString();
                            hd4SizeTextBox.Text = hdSizeString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 5)
                        {
                            hdSizeString = mob.Properties["Size"].Value.ToString();
                            hd5SizeTextBox.Text = hdSizeString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 6)
                        {
                            hdSizeString = mob.Properties["Size"].Value.ToString();
                            hd6SizeTextBox.Text = hdSizeString;
                        }
                    }
                    catch
                    {
                    }

                    hdCounterInteger++;
                }

            return hdSizeString;
        }


        private string GetHdCylinders()
        {
            string hdCylindersString;
            int hdCounterInteger;

            hdCounterInteger = 1;

            hdCylindersString = "Failed to retrieve info.";


                ManagementObjectSearcher managementobjectsearcher = new ManagementObjectSearcher
                ("SELECT * FROM  Win32_DiskDrive");

                ManagementObjectCollection managementobjectcollection = managementobjectsearcher.Get();

                foreach (ManagementObject mob in managementobjectcollection)
                {
                    try
                    {
                        if (hdCounterInteger == 1)
                        {
                            hdCylindersString = mob.Properties["TotalCylinders"].Value.ToString();
                            hdCylindersTextBox.Text = hdCylindersString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 2)
                        {
                            hdCylindersString = mob.Properties["TotalCylinders"].Value.ToString();
                            hd2CylindersTextBox.Text = hdCylindersString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 3)
                        {
                            hdCylindersString = mob.Properties["TotalCylinders"].Value.ToString();
                            hd3CylindersTextBox.Text = hdCylindersString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 4)
                        {
                            hdCylindersString = mob.Properties["TotalCylinders"].Value.ToString();
                            hd4CylindersTextBox.Text = hdCylindersString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 5)
                        {
                            hdCylindersString = mob.Properties["TotalCylinders"].Value.ToString();
                            hd5CylindersTextBox.Text = hdCylindersString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 6)
                        {
                            hdCylindersString = mob.Properties["TotalCylinders"].Value.ToString();
                            hd6CylindersTextBox.Text = hdCylindersString;
                        }
                    }
                    catch
                    {
                    }

                    hdCounterInteger++;
                }

            return hdCylindersString;
        }

        private string GetHdSectors()
        {
            string hdSectorsString;
            int hdCounterInteger;

            hdCounterInteger = 1;

            hdSectorsString = "Failed to retrieve info.";

                ManagementObjectSearcher managementobjectsearcher = new ManagementObjectSearcher
                ("SELECT * FROM  Win32_DiskDrive");

                ManagementObjectCollection managementobjectcollection = managementobjectsearcher.Get();

                foreach (ManagementObject mob in managementobjectcollection)
                {
                    try
                    {
                    if (hdCounterInteger == 1)
                    {
                        hdSectorsString = mob.Properties["TotalSectors"].Value.ToString();
                        hdSectorsTextBox.Text = hdSectorsString;
                    }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 2)
                        {
                            hdSectorsString = mob.Properties["TotalSectors"].Value.ToString();
                            hd2SectorsTextBox.Text = hdSectorsString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 3)
                        {
                            hdSectorsString = mob.Properties["TotalSectors"].Value.ToString();
                            hd3SectorsTextBox.Text = hdSectorsString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 4)
                        {
                            hdSectorsString = mob.Properties["TotalSectors"].Value.ToString();
                            hd4SectorsTextBox.Text = hdSectorsString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 5)
                        {
                            hdSectorsString = mob.Properties["TotalSectors"].Value.ToString();
                            hd5SectorsTextBox.Text = hdSectorsString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 6)
                        {
                            hdSectorsString = mob.Properties["TotalSectors"].Value.ToString();
                            hd6SectorsTextBox.Text = hdSectorsString;
                        }
                    }
                    catch
                    {
                    }

                    hdCounterInteger++;
                }
            

            return hdSectorsString;
        }

        private string GetHdBytesPerSector()
        {
            string hdBytesPerSectorString;
            int hdCounterInteger;

            hdCounterInteger = 1;

            hdBytesPerSectorString = "Failed to retrieve info.";


                ManagementObjectSearcher managementobjectsearcher = new ManagementObjectSearcher
                ("SELECT * FROM  Win32_DiskDrive");

                ManagementObjectCollection managementobjectcollection = managementobjectsearcher.Get();

                foreach (ManagementObject mob in managementobjectcollection)
                {
                    try
                    {
                        if (hdCounterInteger == 1)
                        {
                            hdBytesPerSectorString = mob.Properties["BytesPerSector"].Value.ToString();
                            hdBytesPerSectorTextBox.Text = hdBytesPerSectorString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 2)
                        {
                            hdBytesPerSectorString = mob.Properties["BytesPerSector"].Value.ToString();
                            hd2BytesPerSectorTextBox.Text = hdBytesPerSectorString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 3)
                        {
                            hdBytesPerSectorString = mob.Properties["BytesPerSector"].Value.ToString();
                            hd3BytesPerSectorTextBox.Text = hdBytesPerSectorString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 4)
                        {
                            hdBytesPerSectorString = mob.Properties["BytesPerSector"].Value.ToString();
                            hd4BytesPerSectorTextBox.Text = hdBytesPerSectorString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 5)
                        {
                            hdBytesPerSectorString = mob.Properties["BytesPerSector"].Value.ToString();
                            hd5BytesPerSectorTextBox.Text = hdBytesPerSectorString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 6)
                        {
                            hdBytesPerSectorString = mob.Properties["BytesPerSector"].Value.ToString();
                            hd6BytesPerSectorTextBox.Text = hdBytesPerSectorString;
                        }
                    }
                    catch
                    {
                    }

                    hdCounterInteger++;
                }

            return hdBytesPerSectorString;
        }

        private string GetHdTracks()
        {
            string hdTracksString;
            int hdCounterInteger;

            hdCounterInteger = 1;

            hdTracksString = "Failed to retrieve info.";


                ManagementObjectSearcher managementobjectsearcher = new ManagementObjectSearcher
                ("SELECT * FROM  Win32_DiskDrive");

                ManagementObjectCollection managementobjectcollection = managementobjectsearcher.Get();

                foreach (ManagementObject mob in managementobjectcollection)
                {
                    try
                    {
                        if (hdCounterInteger == 1)
                        {
                            hdTracksString = mob.Properties["TotalTracks"].Value.ToString();
                            hdTracksTextBox.Text = hdTracksString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 2)
                        {
                            hdTracksString = mob.Properties["TotalTracks"].Value.ToString();
                            hd2TracksTextBox.Text = hdTracksString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 3)
                        {
                            hdTracksString = mob.Properties["TotalTracks"].Value.ToString();
                            hd3TracksTextBox.Text = hdTracksString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 4)
                        {
                            hdTracksString = mob.Properties["TotalTracks"].Value.ToString();
                            hd4TracksTextBox.Text = hdTracksString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 5)
                        {
                            hdTracksString = mob.Properties["TotalTracks"].Value.ToString();
                            hd5TracksTextBox.Text = hdTracksString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 6)
                        {
                            hdTracksString = mob.Properties["TotalTracks"].Value.ToString();
                            hd6TracksTextBox.Text = hdTracksString;
                        }
                    }
                    catch
                    {
                    }

                    hdCounterInteger++;
                }

            return hdTracksString;
        }

        private string GetInstallDate()
        {
            string installDateString;
            int hdCounterInteger;

            hdCounterInteger = 1;

            installDateString = "Failed to retrieve info.";

                ManagementObjectSearcher managementobjectsearcher = new ManagementObjectSearcher
                ("SELECT * FROM  Win32_DiskDrive");

                ManagementObjectCollection managementobjectcollection = managementobjectsearcher.Get();

                foreach (ManagementObject mob in managementobjectcollection)
                {
                    try
                    {
                        if (hdCounterInteger == 1)
                        {
                            installDateString = mob.Properties["InstallDate"].Value.ToString();
                            hdInstallDateTextBox.Text = installDateString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 2)
                        {
                            installDateString = mob.Properties["InstallDate"].Value.ToString();
                            hd2InstallDateTextBox.Text = installDateString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 3)
                        {
                            installDateString = mob.Properties["InstallDate"].Value.ToString();
                            hd3InstallDateTextBox.Text = installDateString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 4)
                        {
                            installDateString = mob.Properties["InstallDate"].Value.ToString();
                            hd4InstallDateTextBox.Text = installDateString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 5)
                        {
                            installDateString = mob.Properties["InstallDate"].Value.ToString();
                            hd5InstallDateTextBox.Text = installDateString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 6)
                        {
                            installDateString = mob.Properties["InstallDate"].Value.ToString();
                            hd6InstallDateTextBox.Text = installDateString;
                        }
                    }
                    catch
                    {
                    }

                    hdCounterInteger++;
                }

            return installDateString;
        }

        private string GetHdTracksPerCylinder()
        {
            string hdTracksPerCylinderString;
            int hdCounterInteger;

            hdCounterInteger = 1;

            hdTracksPerCylinderString = "Failed to retrieve info.";


                ManagementObjectSearcher managementobjectsearcher = new ManagementObjectSearcher
                ("SELECT * FROM  Win32_DiskDrive");

                ManagementObjectCollection managementobjectcollection = managementobjectsearcher.Get();

                foreach (ManagementObject mob in managementobjectcollection)
                {
                    try
                    {
                        if (hdCounterInteger == 1)
                        {
                            hdTracksPerCylinderString = mob.Properties["TracksPerCylinder"].Value.ToString();
                            hdTracksPerCylinderTextBox.Text = hdTracksPerCylinderString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 2)
                        {
                            hdTracksPerCylinderString = mob.Properties["TracksPerCylinder"].Value.ToString();
                            hd2TracksPerCylinderTextBox.Text = hdTracksPerCylinderString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 3)
                        {
                            hdTracksPerCylinderString = mob.Properties["TracksPerCylinder"].Value.ToString();
                            hd3TracksPerCylinderTextBox.Text = hdTracksPerCylinderString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 4)
                        {
                            hdTracksPerCylinderString = mob.Properties["TracksPerCylinder"].Value.ToString();
                            hd4TracksPerCylinderTextBox.Text = hdTracksPerCylinderString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 5)
                        {
                            hdTracksPerCylinderString = mob.Properties["TracksPerCylinder"].Value.ToString();
                            hd5TracksPerCylinderTextBox.Text = hdTracksPerCylinderString;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (hdCounterInteger == 6)
                        {
                            hdTracksPerCylinderString = mob.Properties["TracksPerCylinder"].Value.ToString();
                            hd6TracksPerCylinderTextBox.Text = hdTracksPerCylinderString;
                        }
                    }
                    catch
                    {
                    }


                    hdCounterInteger++;
                }

            return hdTracksPerCylinderString;
        }

        private void Drives_Load(object sender, EventArgs e)
        {
            //get hd info
            GetHdModel();
            GetHdManufacturer();
            GetHdSignature();
            GetHdTotalHeads();
            GetHdFirmwareRev();
            GetHdFileSystem();
            GetHdInterfaceType();
            GetHdSerialNumber();
            GetHdSize();
            GetHdCylinders();
            GetHdSectors();
            GetHdBytesPerSector();
            GetHdTracks();
            GetInstallDate();
            GetHdTracksPerCylinder();
        }
















    }
}